<script setup lang="ts">
import { ref } from "vue";

var ipbg = ref(true);

function changeBackground() {
  ipbg.value = !ipbg.value;
}
</script>

<template>
  <button @click="changeBackground">切换背景</button>
  <div :class="{ isred: ipbg, isblue: !ipbg }">part1</div>
</template>
<style scoped>
div {
  width: 200px;
  height: 200px;
}
.isred {
  background: red;
}
.isblue {
  background: blue;
}
</style>
